import { Entity } from "../../core/Entity";
import { ECAttribute, BehaviorMask } from "../../ext/components/ECAttribute";

export abstract class SkillCondition {
    public abstract check(owner: Entity): boolean;
}

// 距离条件
export class DistanceCondition extends SkillCondition {
    constructor(
        private minDistance: number,
        private maxDistance: number
    ) {
        super();
    }
    
    public check(owner: Entity): boolean {
        // 检查距离逻辑
        return true;
    }
}

// 资源条件
export class ResourceCondition extends SkillCondition {
    constructor(
        private resourceType: number,
        private amount: number
    ) {
        super();
    }
    
    public check(owner: Entity): boolean {
        return true;
        // const resource = owner.getComponent(ECAttribute)?.getCurrentValue(this.resourceType) || 0;
        // return resource >= this.amount;
    }
}

// 行为掩码条件
export class BehaviorMaskCondition extends SkillCondition {
    constructor(
        private requiredBehaviors: BehaviorMask
    ) {
        super();
    }
    
    public check(owner: Entity): boolean {
        const attribute = owner.getComponent(ECAttribute);
        if (!attribute) return false;
        return attribute.canPerformBehaviors(this.requiredBehaviors);
    }
}